<script src="/public/library/hvn/captcha.redraw.js" type="text/javascript"></script>
<!-- <script src="/public/library/jquery/jquery.translate-1.3.7.min.js" type="text/javascript"></script>
 -->
<script type="text/javascript">
$(function() {
    $("#ratingButton").click(function(e){
        $.getJSON("/en/place/ajax/rate-place", 
         	{	id: <?= $this->place['id'] ?>, 
        	 	rating: $("#ratingSelect").val()}, 
		        function(json) {
		        	if(json.success)
			            $("#ratingMessage").html(
			                    "Thanks for rating, current rate: " + json.rating + 
			                    " for rating_count: " + json.rating_count + 
			                    " for id: "+ json.id + " average: " + json.average
			                    ); 
			         else
			         	$("#ratingMessage").html("Error: Rated");
		        });
		        return false;
  		 });
});
</script>

<script type="text/javascript">  
$(function() {
    $("a[name^=place-name-edit]").click(function(e){
        id = this.name.split('-')[3];
        $("#place-name-form-" + id).toggle(); 
        return false; 
    });
    
    //the place name text box KeyPress event
    $("input[id^=place-name-text]").bind('keypress', function(e) {
        if (e.keyCode == 13) { //Enter
            $("#place-name-submit-" + id).click();
            return false;
        } 
    });
    
    //submit the new place name
    $("input[id^=place-name-submit]").click(function(e){
        newPlaceName = $("#place-name-text-" + id).val();
        $.getJSON("/en/place/ajax/update-place-name", {'id': id, 'name': newPlaceName},
            function(json) {
                if (json.success)
                {
                    $("#place-name-" + id).html(json.name);
                    $("#place-name-form-" + id).hide();
                }
                else
                    $("#place-name-error-" + id).show().html("Could not insert to DB");
            });
        return false;
    });
	/*
	
	var oriLang = '<?= $this->oriLang?>';
	var lang = '<?= $this->lang?>';
	
	var arr = [ "en", "cn", "jp" ];
    arr = jQuery.map(arr, function (a) { 
    		return ('from:'+'vi' + ','+'to:' + a ); 
    	  });
	if(oriLang != lang)
	{
		if(lang == 'en')
   			$('div.place_desc').translate( { from: 'vi', to: 'en', fromOriginal: true} );
   		if(lang =='cn')
			$('div.place_desc').translate( { from: 'vi', to: 'zh-CN', fromOriginal: true} );
		if(lang == 'jp')
			$('div.place_desc').translate( { from: 'vi', to: 'ja', fromOriginal: true} );
	}
   	*/
});
</script>
<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>
<? if (strpos($sess->userPermissions, 'update place')) :?>
<div style="background-color:#eee;text-align:right">
<a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'edit'))?>?id=<?=$this->place['id']?>"><?=t(135)?></a>
| <a href="<?=$this->hvnUrl(array('module' => 'article', 'action' => 'translate'))?>?id=<?=$this->place['article_data']['article_id']?>&to=en"><?=t(90)?></a>
</div>
<?endif ?>
<!--<?=t(778) ?>: <?= $this->categoryName?> 
<?if (!empty($this->typeName)) :?>
(<?foreach ($this->typeName as $typeName) :?>
	<?=$typeName?>
 <?endforeach?>
)

<?endif?>
-->
<h1><?= $this->place['article_data']['article_title']?></h1>
<br/>
<?if (isset($this->place['article_data'])) :?>
	<span style='color:red;font-size:14px'> <?=$this->errorMessage; ?>&nbsp;&nbsp;
	</span>
	<div class="place_desc">
    	<?=$this->place['article_data']['article_body'] ?>
	</div>
<?else:?>
	<?=t(522) ?>
<?endif?>

<br/>


<!--<?=t(775) ?>: #<?= $this->place['id']?>
<br/>
<?=t(776) ?>:   <span id="place-name-<?=$this->place['id']?>" name="<?=$this->place['id']?>"><?= $this->place['name']?></span>
        <span id="place-name-error-<?=$this->place['id']?>" style='font-size:10px;color:red'></span>
        <a href="javascript:void()" name="place-name-edit-<?=$this->place['id']?>"><?=t(38) ?></a>
            <div id="place-name-form-<?=$this->place['id']?>" style="display:none">
                <input type='text' id='place-name-text-<?=$this->place['id']?>' value="<?= $this->place['name']?>"/> <br/>
                <input type='button' value='Go' id='place-name-submit-<?=$this->place['id']?>'/>
            </div>    
<br/>
-->
<br/>
<div class="address" style="background-image: url(/public/themes/prime/images/left/view_place/bg_place1.gif); background-repeat: repeat; height:96px">
	<?$metadata = unserialize($this->place['metadata']);?>
	<div style="float:left; width:210px">
		<br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(777) ?>: <!--<?= $this->hvnAddress($this->address);?>--><?if(isset($metadata['city_name'])):?>
			<?=$metadata['city_name']?><?endif?>
		<br/><br/>
		<?if($this->place['rtype'] != 17) :?>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(750) ?>: <?if(isset($metadata['phone'])) :?><?=$metadata['phone']?><?endif?>
		<br/><br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(751) ?>: <?if(isset($metadata['fax'])) :?><?=$metadata['fax']?><?endif?>
	</div>
	<div style="float:left; width:210px">
		<br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(470) ?>: <?if(isset($metadata['contact_email'])) :?><?=$metadata['contact_email']?><?endif?>
		<br/><br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(824) ?>: <?if(isset($metadata['website'])) :?><?=$metadata['website']?><?endif?>
		<?endif?>
	</div>
	<div style="float:left; width:210px; border-left: 1px solid #D6D6D6; padding-left:5px">
	<br/>
		<a href="#"><img src="/public/themes/prime/images/content_bottom/introduction31x31.png" border="0" width="12px" height="12px"/><?=t(156) ?></a><br/><br/>
		<a href="#"><img src="/public/themes/prime/images/content_bottom/contact us29x29.png" border="0" width="12px" height="12px"/> <?=t(157) ?></a><br/><br/>
		<a href="#"><img src="/public/themes/prime/images/left/comments/loibinh.png" border="0" width="12px" height="12px"/> <?=t(602) ?></a>
	</div>
	<div style="clear:both"></div>
</div>

<br/>
<div style="background-image: url(/public/themes/prime/images/left/view_place/bg_place1.gif); background-repeat: repeat; height:96px">
	<div style="float:left; width:210px">
		<br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
		<?=t(768) ?>:<?=$this->place['opening_hours']?>
		<br/><br/>
		<?if (isset($this->place['fee_currency'])) :?>   
		<img src="/public/themes/prime/images/left/comments/arrow.png" /> 
		<?=t(764) ?>:<?if(isset($this->place['fee_currency'])) :?><?= $this->place['fee_currency']?> <?endif?>
					<?= $this->place['fee']?>/<?if(isset($this->place['fee_basis'])) :?><?= p($this->place['fee_basis'])?><?endif?>
		<?endif?>
		 <br/>
	</div>
	
	<div style="float:left; width:210px; ">
		<?if($this->place['rtype'] == 17) :?>
			<br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(755) ?>: <?=$this->built_year?>
			<br/><br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(754) ?>: <?=$this->festive_days_from ?>
			<br/><br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(753) ?>: <?=$this->festive_days_to ?>
		<?endif?>
		<?if($this->place['rtype'] == 20 && $this->place['type'] == 45):?>
			<br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(758) ?>: <?=$this->take_away?>
			<br/><br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(759) ?>: <?=$this->delivery?>
			<br/><br/>
			<img src="/public/themes/prime/images/left/comments/arrow.png" />
			<?=t(757) ?> :<?=$this->meals?>
		<?endif?>
		
		<?$hotel = Zend_Registry::get('configuration')->hotel;?>
		<?foreach ($hotel as $k => $h) :?>
    		<?if ($this->place['rtype'] == $h):?>
    			<br/>
    			<img src="/public/themes/prime/images/left/comments/arrow.png" />
    			<?=t(747) ?>:<?=$this->place['number_of_rooms']?>
    			<br/><br/>
    			<img src="/public/themes/prime/images/left/comments/arrow.png" />
    			<?=t(748) ?>:<?=$this->place['number_of_available_rooms']?>
    		<?endif?>
    	<?endforeach?> 
	</div>
	
	<div style="float:left; width:210px;">
		<br/>
		<img src="/public/themes/prime/images/left/comments/arrow.png" />
	</div>
	<div style="clear:both"></div>
</div>

<br/>
<!--<//?=t(779) ?>--> 

<br/>
<a href="<?=$this->hvnUrl(array('module' => 'event', 'action' => 'new'))?>?place_id=<?=$this->place['id']?> & place_name=<?=$this->place['name']?>"><?=t(216) ?></a>

<?=t(117) ?>:
<select id="ratingSelect">
<? for($i = 1; $i <= Zend_Registry::get('configuration')->maxRating; $i++) :?>
    <option value="<?=$i?>"><?=$i?></option>
<?endfor?>
</select>
<input type="button" id="ratingButton" value="Go" />
<br/><span id="ratingMessage"> </span>
<br/>
